#include <iostream>
#include <openssl/rand.h>

int main() {
    const int numBytes = 16;  // 要生成的随机字节数
    unsigned char buffer[numBytes];

    // 初始化 OpenSSL 的随机数发生器
    RAND_poll();

    // 生成随机数
    int success = RAND_bytes(buffer, numBytes);

    if (success == 1) {
        // 打印生成的随机字节序列
        std::cout << "Random Bytes: ";
        for (int i = 0; i < numBytes; ++i) {
            std::cout << std::hex << static_cast<int>(buffer[i]);
        }
        std::cout << std::endl;
    } else {
        std::cerr << "Error generating random bytes." << std::endl;
    }

    return 0;
}

